package com.ruoyi.project.system.material.center.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.common.utils.uniquekey.IdGererateFactory;
import com.ruoyi.project.system.material.center.domain.MaterialCenter;
import com.ruoyi.project.system.material.center.mapper.MaterialCenterMapper;
import com.ruoyi.project.system.material.center.service.IMaterialCenterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 素材中心Service业务层处理
 * 
 * @author LCL
 * @date 2021-01-21
 */
@Service
public class MaterialCenterServiceImpl implements IMaterialCenterService
{
    @Autowired
    private MaterialCenterMapper materialCenterMapper;
    @Resource
    private IdGererateFactory idGererateFactory;

    /**
     * 查询素材中心
     * 
     * @param id 素材中心ID
     * @return 素材中心
     */
    @Override
    public MaterialCenter selectMaterialCenterById(String id)
    {
        return materialCenterMapper.selectMaterialCenterById(id);
    }

    /**
     * 查询素材中心列表
     * 
     * @param materialCenter 素材中心
     * @return 素材中心
     */
    @Override
    public List<MaterialCenter> selectMaterialCenterList(MaterialCenter materialCenter)
    {
        return materialCenterMapper.selectMaterialCenterList(materialCenter);
    }

    /**
     * 新增素材中心
     * 
     * @param materialCenter 素材中心
     * @return 结果
     */
    @Override
    public int insertMaterialCenter(MaterialCenter materialCenter)
    {
        materialCenter.setId(this.idGererateFactory.nextStringId());
        materialCenter.setCreated(DateUtils.getNowDate());
        return materialCenterMapper.insertMaterialCenter(materialCenter);
    }

    /**
     * 修改素材中心
     * 
     * @param materialCenter 素材中心
     * @return 结果
     */
    @Override
    public int updateMaterialCenter(MaterialCenter materialCenter)
    {
        return materialCenterMapper.updateMaterialCenter(materialCenter);
    }

    /**
     * 删除素材中心对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMaterialCenterByIds(String ids)
    {
        return materialCenterMapper.deleteMaterialCenterByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除素材中心信息
     * 
     * @param id 素材中心ID
     * @return 结果
     */
    @Override
    public int deleteMaterialCenterById(String id)
    {
        return materialCenterMapper.deleteMaterialCenterById(id);
    }

    @Override
    public List<MaterialCenter> findMaterialList() {
        return materialCenterMapper.findMaterialList();
    }
}
